#include <iostream>
#include <cstdio>
#include <cassert>
#include <pthread.h>
#include <unistd.h>

void* thread_routine(void* arg)
{
    const char* name = (const char*)arg;
    while(true)
    {
        std::cout << "我是新线程，名字是：" << name << std::endl;
        sleep(1);
    }
}

int main()
{
    pthread_t tid;// 线程id
    int ret = pthread_create(&tid, nullptr, thread_routine, (void*)"thread_one");
    assert(ret == 0);
    (void)ret;

    char tidbuffer[64];
    snprintf(tidbuffer, sizeof(tidbuffer) - 1, "0x%x", tid);

    while(true)
    {
         while(true)
        {
            std::cout << "我是主线程，tid：" << tidbuffer << std::endl;
            // tid：140077005076224

            sleep(1);
        }
    }

    return 0;
}